#!/usr/bin/python
# -*- coding: UTF-8 -*-
import time
start = time.clock()

n = 1000000
k = 0
maximum = 0

while ( n > 0):
  m=n
  k = 0
  while ( m != 1 ):
    if ( m % 2 == 0 ):
      m /= 2
    else :
      m = m * 3 + 1
    k += 1
  if ( maximum < k ):
    result = n
    maximum = k
    print maximum
  n-=1

print result, maximum
print "problem solved in ", (time.clock() - start), "s"
